package com.itheima.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一返回结果类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {

    private Integer code; //1成功  0失败
    private String msg; //错误消息
    private Object data; //数据

    //添加两个静态方法（成功、失败）
    public static R ok() {
        return new R(1, "操作成功", null);
    }

    public static R ok(Object data) {
        return new R(1, "操作成功", data);
    }

    public static R error(String msg) {
        return new R(0, msg, null);
    }

}
